<template>
    <check-process v-bind="$attrs" :detail="detail" :disabled="disabled" :historyList="historyList" ref="checkPrecessRef" />
</template>

<script lang="ts">
import CheckProcess from '@/views/version/versionDetail/components/RelateProcess/CheckProcess/index.vue';
import store from '@/store';
import { defineComponent, ref, unref, computed } from 'vue';
export default defineComponent({
    components: {
        CheckProcess
    },
    props: {
        detail: {
            type: Object,
            default: () => ({})
        },
        historyList: { type: Array, default: () => [] },
        hasAuth: { type: Boolean, default: false }
    },
    setup(props) {
        const checkPrecessRef = ref<any>();
        const form = computed(() => {
            return unref(checkPrecessRef).form;
        });
        // 是否显示流程模块
        const disabled = computed(() => {
            // 已发布的或者是挂起等节点不显示
            if (+props.detail.status >= 3) {
                return true;
            } else {
                if (props.historyList.length) {
                    // 是否自动提测
                    if (props.detail.pmpTestInformationDTO) {
                        // 需求测试和测试经理审核无需判断
                        if (props.detail.processStatus === '6') {
                            return false;
                        }
                    }
                    // 审批节点操作人不是当前用户的无需显示
                    return !props.hasAuth;
                } else {
                    return props.detail.createUserEmpId !== unref(store.getters.userInfo.employeeDTO.empId);
                }
            }
        });
        return {
            checkPrecessRef,
            form,
            disabled
        };
    }
});
</script>